package a.b.config;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

@RestController
public class PeopleController {

    @Autowired
    MeterRegistry meterRegistry;

    private Counter addCounter;
    private Counter subCounter;

    @PostConstruct
    public void setup() {
        addCounter = meterRegistry.counter("people_req_counter","people","add");
        subCounter = meterRegistry.counter("people_req_counter","people","sub");
    }

    @GetMapping("/add")
    public String g() {
        addCounter.increment();
        return "OK";
    }

    @GetMapping("/sub")
    public String g1() {
        subCounter.increment();
        return "OK";
    }

}
